<script lang="ts" setup>
import 'element-plus/dist/index.css'
import { reactive } from 'vue'

const form = reactive({
    name: '将110kVk流沙站10kV流沙线abc #1杆 1T1开关由运行转检修',
    before_operation: '',
    after_operation: '',
    automated_switch: false,
    high_voltage_circuit_breaker: '',
})

const onSubmit = async () => {
    void localSwitchname.setValue(form.name);
    void localSwitchbefore.setValue(form.before_operation);
    void localSwitchafter.setValue(form.after_operation);
    void localSwitchcircuitbreaker.setValue(form.high_voltage_circuit_breaker);
    void localSwitchtype.setValue(form.automated_switch);

    SwitchOutput(form.name,form.before_operation,form.after_operation,form.high_voltage_circuit_breaker,form.automated_switch);
}
const onClean = () => {
    form.name='';
    form.before_operation='';
    form.after_operation='';
    form.high_voltage_circuit_breaker='';
    form.automated_switch=false;
}
const onReload= async () => {
    form.name=await localSwitchname.getValue();
    form.before_operation=await localSwitchbefore.getValue();
    form.after_operation=await localSwitchafter.getValue(form.after_operation);
    form.high_voltage_circuit_breaker=await localSwitchcircuitbreaker.getValue();
    form.automated_switch=await localSwitchtype.getValue();
}
const rules={
    name:[
        {required:true,pattern:/[0-9]+T[0-9]/,message:'请输入开关编号',trigger:'blur'}     
    ],
}
</script>
<template>
    <el-form :model="form" :rules="rules" size="small" label-position="left" label-width="auto">
        <el-form-item label="设备名称：" prop="name" >
            <el-input v-model="form.name"  placeholder="将110kVXX站10kVXX线abc 1T1开关由运行转检修" spellcheck="false"/>
        </el-form-item>
        <el-form-item label="操作前：">
            <el-select v-model="form.before_operation"   :teleported="false">
            <el-option label="运行" value="运行" />
            <el-option label="检修" value="检修" />
            </el-select>
        </el-form-item>
        <el-form-item label="操作后：">
            <el-select v-model="form.after_operation"   :teleported="false">
            <el-option label="运行" value="运行" />
            <el-option label="检修" value="检修" />
            </el-select>
        </el-form-item>
        <el-form-item label="高压刀闸：">
        <el-radio-group v-model="form.high_voltage_circuit_breaker">
            <el-radio value="1">单刀闸</el-radio>
            <el-radio value="2">双刀闸</el-radio>
        </el-radio-group>
        </el-form-item>
        <el-form-item label="自动化开关 ">
            <el-switch v-model="form.automated_switch" />
        </el-form-item>
        <el-form-item>
            <el-button type="success" @click="onSubmit">生成操作票</el-button>
            <el-button type="danger" @click="onClean">清空参数</el-button>
            <el-button type="primary" @click="onReload">加载上次参数</el-button>
        </el-form-item>
    </el-form>
</template>

<style scoped>
</style>